import { IResult } from './interface';

export class ResultBuilder {
  /* private data: any = {};
  private code = 200;
  private message = '';
  constructor(data = {}, code?: number, message = '') {
    this.data = data;
    this.code = code;
    this.message = message;
  } */
  static build(code: number, message = '', data = {}): IResult {
    return {
      data,
      code,
      message,
    };
  }
  static ok(): IResult {
    return this.build(200, 'success');
  }
  static okWith(data: any): IResult {
    return this.build(200, 'success', data);
  }
  static fail() {
    return this.build(403, '请求失败');
  }
  static failWith(message: string) {
    return this.build(403, message);
  }
}
